use member brace initializes and default constructors. (#214)
authortsteven4 <tsteven4@users.noreply.github.com>
Sat, 30 Jun 2018 21:05:55 +0000 (15:05 -0600)
committerGitHub <noreply@github.com>
Sat, 30 Jun 2018 21:05:55 +0000 (15:05 -0600)
defs.h
googledir.cc
jeeps/gps.h
kml.cc
main.cc
mmo.cc
tpo.cc

diff --git a/defs.h b/defs.h
index 1261d9d3cbe133f3fe7f65d88ab205d461c82656..eb5a0be1070b002b1c0b9905e2061de6d54e6ecf 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -253,10 +253,12 @@ typedef enum {
 class utf_string
 {
 public:
-  utf_string() :
-    is_html(false)
-  {};
-  bool is_html;
+  utf_string() = default;
+  utf_string(bool html, const QString& str) :
+    is_html{html},
+    utfstring{str}
+  {}
+  bool is_html{false};
   QString utfstring;
 };
 
@@ -312,11 +314,8 @@ typedef struct format_specific_data {
 class gb_color
 {
 public:
-  gb_color() :
-    bbggrr(-1),
-    opacity(255) {}
-  int bbggrr;   // 32 bit color: Blue/Green/Red.  < 0 == unknown.
-  unsigned char opacity;  // 0 == transparent.  255 == opaque.
+  int bbggrr{-1};   // 32 bit color: Blue/Green/Red.  < 0 == unknown.
+  unsigned char opacity{255};  // 0 == transparent.  255 == opaque.
 };
 
 
@@ -340,7 +339,7 @@ void fs_chain_add(format_specific_data** chain, format_specific_data* data);
 class UrlLink
 {
 public:
-  UrlLink() { }
+  UrlLink() = default;
   UrlLink(const QString& url) :
     url_(url)
   { }
index aa6a6983457e36cfec5441cc2b9ffdcdea20b39f..c23af727f5f2289af029057d24fcfe7f85290024 100644 (file)
@@ -103,9 +103,7 @@ goog_poly_e(xg_string args, const QXmlStreamAttributes*)
     if (instructions == nullptr) {
       routehead->rte_desc = QString("Step %1").arg(goog_step);
     } else {
-      utf_string utf;
-      utf.is_html = true;
-      utf.utfstring = instructions;
+      utf_string utf(true, instructions);
       char *s = strip_html(&utf);
       routehead->rte_desc = s;
       xfree(s);
index b897f89d7498ca4c580d933196cb7584bd923ce3..a33f1fb80ab28ed67cbec813960b2c7464079888 100644 (file)
@@ -39,12 +39,9 @@ typedef struct GPS_SPacket {
 
 class GPS_PPacket {
 public:
-  GPS_PPacket() : type(0), n(0) {
-    memset(data, 0, MAX_GPS_PACKET_SIZE);
-  }
-  US type;
-  uint32 n;
-  UC data[MAX_GPS_PACKET_SIZE];
+  US type{0};
+  uint32 n{0};
+  UC data[MAX_GPS_PACKET_SIZE]{};
 };
 
 
diff --git a/kml.cc b/kml.cc
index c8642eb2777b05ed74b561a3b68d98109225cf25..5c4c2d231d325317ceefbe9541ec3ab01db4a8d7 100644 (file)
--- a/kml.cc
+++ b/kml.cc
@@ -198,8 +198,8 @@ struct {
 #define ICON_DIR ICON_BASE "track-directional/track-%1.png" // format string where next arg is rotational degrees.
 
 static struct {
-  float seq;
-  float step;
+  float seq{0.0f};
+  float step{0.0f};
   gb_color color;
 } kml_color_sequencer;
 #define KML_COLOR_LIMIT 204    /* allowed range [0,255] */
diff --git a/main.cc b/main.cc
index 62a632d046e4660d00b78d58c4074ae46c8ad573..622ae8076083a228818642b71886fdc887a07f52 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -50,7 +50,7 @@ void signal_handler(int sig);
 class QargStackElement
 {
 public:
-  int argn;
+  int argn{0};
   QStringList qargs;
 
 public:
diff --git a/mmo.cc b/mmo.cc
index 98565698123b0db33711a5864734846a6efef863..6bf6823a8eca3eea8ac5377586e79fcd836d03cd 100644 (file)
--- a/mmo.cc
+++ b/mmo.cc
@@ -1291,10 +1291,7 @@ mmo_write_wpt_cb(const Waypoint* wpt)
     char* kml = nullptr;
 
     if (strcmp(wpt->session->name, "kml") == 0) {
-      utf_string tmp;
-
-      tmp.utfstring = cx;
-      tmp.is_html = true;
+      utf_string tmp(true, cx);
       cx = kml = strip_html(&tmp);
     }
     str += cx;
diff --git a/tpo.cc b/tpo.cc
index 5ef416d6008d6e2d012101bfda976cc5155db00f..d1036e296de21ceefa5aed009fb4a3c476b14246 100644 (file)
--- a/tpo.cc
+++ b/tpo.cc
@@ -495,16 +495,10 @@ static Waypoint* tpo_convert_ll(int lat, int lon)
 #define TRACKNAMELENGTH 256
 class StyleInfo {
 public:
-  StyleInfo() {
-    color[0] = 0;
-    color[1] = 0;
-    color[2] = 0;
-    wide = dash = 0;
-  }
   QString name;
-  uint8_t color[3];  // keep R/G/B values separate because line_color needs BGR
-  uint8_t wide;
-  uint8_t dash;
+  uint8_t color[3]{0, 0, 0};  // keep R/G/B values separate because line_color needs BGR
+  uint8_t wide{0};
+  uint8_t dash{0};
 };
 
 // Track decoder for version 3.x files.  This block contains tracks